/* Author: Mark Mckillion, Chris Mowbray
 * Date: 17/04/2012
 * Version 1.0.*/


/*
 * This is a thread that will be used to slow down all the sorting methods so 
 * that it can be easily followed by the user dependng on the users input of the
 * speed in which they want to thread to run.
 */
package assignment4;

public class DelayThread implements Runnable {

    public void run() {
        // String to hold the slected string for the drop down box.
        String srtAlgorithm;
        srtAlgorithm = String.valueOf(ControlPanel.jComboBox1.getSelectedItem());
        
// if string = bubble then sort the objects using the bubble method
        if (srtAlgorithm.equals("Bubble")) {
            if (ControlPanel.jComboBox3.getSelectedItem().equals("Colour")) {
                BubbleSort.sortObjects(Colour.colors);
            }
            if (ControlPanel.jComboBox3.getSelectedItem().equals("Vehicle")) {
                BubbleSort.sortObjects(Vehicle.vehicles);
            }
        }
// if string = insertion then sort the objects using the insertion method
        if (srtAlgorithm.equals("Insertion")) {
            if (ControlPanel.jComboBox3.getSelectedItem().equals("Colour")) {
                InsertionSort.sortObjects(Colour.colors);
            }
            if (ControlPanel.jComboBox3.getSelectedItem().equals("Vehicle")) {
                InsertionSort.sortObjects(Vehicle.vehicles);
            }
        }
// if string = selection then sort the objects using the selection method
        if (srtAlgorithm.equals("Selection")) {
            if (ControlPanel.jComboBox3.getSelectedItem().equals("Colour")) {
                SelectionSort.sortObjects(Colour.colors);
            }
            if (ControlPanel.jComboBox3.getSelectedItem().equals("Vehicle")) {
                SelectionSort.sortObjects(Vehicle.vehicles);
            }
        }
    }
}   //End of DelayThread class.